package jm.java.heap;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 堆内存溢出
 * @date 2022/3/17 17:02
 */
public class HeapOverflow {
    public static void main(String[] args) {
        int i = 0;
        try {
            List<String > list = new ArrayList<>();
            String a = "hello";
            while (true){
                list.add(a);
                a = a + a;
                i++;
            }
        }catch (Throwable e){
            e.printStackTrace();
            System.out.println(i);
        }
    }
}
